library(tidyverse)
library(DeclareDesign)
library(rdss)

source("code/declarations/declaration_2.1.R")
source("code/declarations/declaration_2.2.R")

sims <- 2000
bootstrap_sims <- 2000

program_diagnosands  <-
  declare_diagnosands(
    success = mean(estimate > 0.3 & p.value < 0.05  & estimand > 0.2),
    failure = mean(estimate > 0.3 & p.value < 0.05  & estimand < 0.2)
  )

designs_1 <- declaration_2.1 |> redesign(b = seq(0, 3, 0.25))
designs_2 <- declaration_2.2 |> redesign(b = seq(0, 3, 0.25))

names(designs_1) <- paste0(names(designs_1), "twoarm")
names(designs_2) <- paste0(names(designs_2), "blocked")
designs <- c(designs_1, designs_2)

diagnosis <-
  diagnose_design(designs, sims = sims, bootstrap_sims = bootstrap_sims, diagnosands = program_diagnosands)

write_rds(diagnosis, file = "diagnosis_objects/diagnosis_2.1.rds")
